package csc.fresher.utils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.apache.log4j.Logger;

public class DBUtils {
	
	
	public static void closeConnection(Connection connection, PreparedStatement preparedStatement, Logger logger){
		try {
			if (preparedStatement != null) {
				preparedStatement.close();
			}
			if (connection != null) {
				connection.close();
			}
		} catch (SQLException e) {
			logger.error(e);
			e.printStackTrace();
		}
	}
	
	public static void closeResultSetConnection(Connection connection, PreparedStatement preparedStatement, ResultSet rs, Logger logger){
		try {
			if (rs != null) {
				rs.close();
			}
			if (preparedStatement != null) {
				preparedStatement.close();
			}
			if (connection != null) {
				connection.close();
			}
		} catch (SQLException e) {
			logger.error(e);
			e.printStackTrace();
		}
	}
}
